
function sendMessage(messageText) {
    messageText = messageText || $("message").value;

    $('spinImg').show();
    
    new Ajax.Request("/messages", {
        method: "post",
        
        parameters: {
            message: messageText,
            author: $("author").value,
        },
        
        onSuccess: function(transport) {
            $("messageChat").innerHTML = transport.responseText;
            $('spinImg').hide();
        },
        
        onFailure: function(transport) {
            alert("me bad");
            $('spinImg').hide();
        }
    });
}